package com.halixun.d2app.adapter.holder;

import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.halixun.d2app.R;
import com.halixun.d2app.adapter.NavigationAdapter;
import com.halixun.d2app.base.BaseViewHolder;
import com.halixun.d2app.bean.SettingInfo;

/**
 * @ProjectName: D2App
 * @Package: com.halixun.d2app.adapter.holder
 * @ClassName: NavigationViewHolder
 * @Description: java类作用描述
 * @Author: hdx
 * @CreateDate: 2019/12/3 17:44
 * @UpdateUser: hdx
 * @UpdateDate: 2019/12/3 17:44
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class NavigationViewHolder extends BaseViewHolder<SettingInfo> {

    private TextView name;

    private NavigationAdapter.SettingNavigationListener listener;

    public NavigationViewHolder(View itemView) {
        super(itemView);
        initView();
        setListeners();
    }

    public NavigationViewHolder(View itemView, NavigationAdapter.SettingNavigationListener listener) {
        this(itemView);
        this.listener = listener;
    }

    private void setListeners() {
        itemView.setOnClickListener(v -> {
            if (null!=listener){
                listener.onSettingNavigationClickListener(getAdapterPosition());
            }
        });
    }

    private void initView() {
        name = itemView.findViewById(R.id.name);
    }

    @Override
    public void setLayoutInfo(SettingInfo info) {
        name.setText(info.title);
        name.setTextColor(Color.parseColor(info.isSelected?"#FF4B01":"#444444"));
    }
}
